package com.example.guiguiapplicatio.fragment.home.adapter;


import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;


import com.example.guiguiapplicatio.R;
import com.example.guiguiapplicatio.databinding.FragmentServiceRecyItemBinding;
import com.example.guiguiapplicatio.placeholder.PlaceholderContent.PlaceholderItem;

import java.util.List;

public class ServiceFragmentAdapter extends RecyclerView.Adapter<ServiceFragmentAdapter.ViewHolder> {

    private final List<PlaceholderItem> mValues;

    public ServiceFragmentAdapter(List<PlaceholderItem> items) {
        mValues = items;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

        return new ViewHolder(FragmentServiceRecyItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.mItem=mValues.get(position);
        holder.binding.servicerecyAge.setText(mValues.get(position).id);
        if (mValues.get(position).id.equals(String.valueOf(1))){
            holder.binding.servicerecyStatus.setBackgroundResource(R.drawable.status_label_daishenhe);
            holder.binding.servicerecyStatus.setText("待审核");
        }else if (mValues.get(position).id.equals(String.valueOf(2))){
            holder.binding.servicerecyStatus.setBackgroundResource(R.drawable.status_label_daizhifu);
            holder.binding.servicerecyStatus.setText("待支付");
        }else if (mValues.get(position).id.equals(String.valueOf(3))){
            holder.binding.servicerecyStatus.setBackgroundResource(R.drawable.status_label_shengxiao);
            holder.binding.servicerecyStatus.setText("已生效");
        }else {
            holder.binding.servicerecyStatus.setBackgroundResource(R.drawable.status_label_bohui);
            holder.binding.servicerecyStatus.setText("已驳回");
        }
    }

    @Override
    public int getItemCount() {
        return mValues.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        FragmentServiceRecyItemBinding binding;
        public PlaceholderItem mItem;
        public ViewHolder(@NonNull FragmentServiceRecyItemBinding fragmentServiceRecyItemBinding) {
            super(fragmentServiceRecyItemBinding.getRoot());
            this.binding=fragmentServiceRecyItemBinding;
        }
    }
}





